Initialize Packages
A cell with all the import
md"""
# Initialize Packages
A cell with all the import
"""
begin
using PlutoUI , LinearAlgebra , Images , ImageShow
end
Read and Display Image
md"""
# Read and Display Image
"""
"https://user-images.githubusercontent.com/6933510/107239146-dcc3fd00-6a28-11eb-8c7b-41aaf6618935.png"
url = "https://user-images.githubusercontent.com/6933510/107239146-dcc3fd00-6a28-11eb-8c7b-41aaf6618935.png"
# url ="https://www.google.com/url?sa=i&url=https%3A%2F%2Funsplash.com%2Fs%2Fphotos%2Fegyptian-cat&psig=AOvVaw1xYgdNItObx3eNC5OH7KFT&ust=1649752004968000&source=images&cd=vfe&ved=0CAoQjRxqFwoTCKjvyaTLi_cCFQAAAAAdAAAAABAD"
"/tmp/jl_wNDcXXYnBU"
philip_fname = download(url )
Enter cell code...
philip = load(philip_fname )
Enter cell code...
Simple Julia Function and Broadcasting
md"""
# Simple Julia Function and Broadcasting
"""
double (generic function with 1 method)
function double(x)
return x *2
end
4.0
3×3 Matrix{Int64}:
1 2 4
2 3 4
8 9 24
a = [1 2 4
2 3 4
8 9 24]
3×3 Matrix{Int64}:
2 4 8
4 6 8
16 18 48
3×3 Matrix{Int64}:
1 2 4
2 3 4
8 9 24
flatten (generic function with 1 method)
flatten(a)=a [1:1:length(a )] # Flattens a matrix column wise
1
2
8
2
3
9
4
4
24
Enter cell code...
Taking Camera Input
This will not work on the remote server
md"""
# Taking Camera Input
This will not work on the remote server
"""
@bind image_data FilePicker([MIME("image/jpg"), MIME("image/png")])
MethodError: no method matching getindex(::Nothing, ::String)
- top-level scope@Local: 1[inlined]
# @bind fname file_input()
myface1=philip
[
]
[philip philip [:, end:-1:1]]
Inspecting your data
md"""
# Inspecting your data
"""
864
700
size(philip )
1
1
row_i, col_i = (1,1)
Slider(1:10)
Slider(1:10, show_value=true)
PlutoUI
PlutoUI3
begin
row_start, row_end = (1,100)
col_start, col_end = (1,100)
md"""
PlutoUI $(@bind row_start Slider(1:size(philip)[1], show_value=true))
PlutoUI2 $(@bind row_end Slider(1:size(philip)[1], show_value=true))
PlutoUI3 $(@bind col_start Slider(1:size(philip)[2], show_value=true))
PlutoUI4 $(@bind col_end Slider(1:size(philip)[2], show_value=true))
"""
end
reduced_phil = philip [row_start :row_end , col_start :col_end ]
save( "reduced_phil2.png", reduced_phil )
1
864
size(philip )[1]
Julia: Array Data Structure
md"""
# Julia: Array Data Structure
"""
1
20
"hello"
[1, 20, "hello"]
[RGB(1,0,0), RGB(0,1,0), RGB(0,0,1)]
[RGB(1,0,0) RGB(0,1,0)
RGB(0,0,1) RGB(0.5, 0.5, 0.5)]
[RGB(x ,0,0) for x in 0:0.1:1]
[RGB(i , j, 0) for i in 0:0.1:1, j in 0:0.1:1]
[RGB(i , j, 0) for i in 0:0.1:1, j in 0:0.1:1]
philip_head = reduced_phil
[philip_head reverse(philip_head , dims=2)
reverse(philip_head , dims=1) rot180(philip_head )]
@bind number_reds Slider(1:100, show_value=true)
[RGB(red_value / number_reds , 0, 0) for red_value in 0:number_reds ]
Utils
This contains all the utilities used in the pluto notebook. For pluto reactive working style , it is recommended to collect utilities at the end
md"""
# Utils
This contains all the utilities used in the pluto notebook. For pluto reactive working style , it is recommended to collect utilities at the end
"""
camera_input (generic function with 1 method)
function camera_input(;max_size=150, default_url="https://i.imgur.com/SUmi94P.png")
"""
<span class="pl-image waiting-for-permission">
<style>
.pl-image.popped-out {
position: fixed;
top: 0;
right: 0;
z-index: 5;
}
.pl-image #video-container {
width: 250px;
}
.pl-image video {
border-radius: 1rem 1rem 0 0;
}
.pl-image.waiting-for-permission #video-container {
display: none;
}
.pl-image #prompt {
display: none;
}
.pl-image.waiting-for-permission #prompt {
width: 250px;
height: 200px;
display: grid;
place-items: center;
font-family: monospace;
font-weight: bold;
text-decoration: underline;
cursor: pointer;
border: 5px dashed rgba(0,0,0,.5);
}
file_input (generic function with 1 method)
function file_input()
"""
<form>
<label for="fname">File Name</label>
<input type="file" id="fname" name="fname"><br><br>
</form>
"""|>HTML
end
HTML()